package server;

import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * RMI server.
 * @author ernesta
 */
public class Server {
    public static void main(String[] args) {
        int port = 44444;
        String host = "192.168.239.10";
        
        if (args.length > 0) host = args[0];
        if (args.length > 1) port = Integer.parseInt(args[1]);
        
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        
        try {
            ServerHandler server = new ServerHandler();
            Registry registry = LocateRegistry.getRegistry(host, port);
            registry.rebind("server", server);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}